package com.woniuxy.utils;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * description: ParseJwtTest <br>
 * date: 2021/12/4 4:13 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */
//解密
public class ParseJwtTest {
    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5OTkiLCJzdWIiOiJhZG1pbiIsInBhc3N3b3JkIjoiMTIzNDU2IiwiY3JlYXRldGllbSI6MTYzODYwNzg2ODc1Mywicm9sZXMiOiJlZGl0IiwiZXhwIjoxNjM4NjA3OTg4LCJpYXQiOjE2Mzg2MDc4Njh9.Z8S5bTx3A-9RqwG_qTGQ0mL6XqFYOWk8dww-C2PctBI";
        Claims woniuxy = Jwts.parser().setSigningKey("woniuxy").parseClaimsJws(token)
                .getBody();
        System.out.println(woniuxy.getId());
        System.out.println(woniuxy.getSubject());
        System.out.println(woniuxy.getIssuedAt());
        System.out.println(woniuxy.get("password"));
        System.out.println(woniuxy.get("roles"));
    }
}
